class Solution(object):
    def isPathCrossing(self, path):
        already = {(0, 0)}
        now = (0, 0)
        for c in path:
            if c == 'N':
                now = (now[0], now[1] + 1)
            if c == 'S':
                now = (now[0], now[1] - 1)
            if c == 'E':
                now = (now[0] + 1, now[1])
            if c == 'W':
                now = (now[0] - 1, now[1])
            if now in already:
                return True
            already.add(now)
        return False
